﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web;

/// <summary>
/// Summary description for ProDepartment
/// </summary>
public class ProDepartment
{
	public ProDepartment()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public DataSet LoadDept()
    {
        DataSet ds = new DataSet();
        ConnectDB db = new ConnectDB();
        ds = db.getDept();
        return ds;
    }

    public Boolean SaveDept(Department dpm)
    {
        Boolean bResult = false;
        ConnectDB db = new ConnectDB();
        bResult = db.saveDept(dpm);

        return bResult;
    }

    //true: exist; false: not exist
    public Boolean CheckDeptExist(String nameofdept)
    {
        Boolean result = false;
        ConnectDB db = new ConnectDB();
        DataSet ds = new DataSet();
        ds = db.checkExistDept(nameofdept);
        if (ds.Tables[0].Rows.Count == 0)
            result = false;
        else
            result = true;
        return result;
    }

    public Boolean DeleteDept(Department dpm)
    {
        ConnectDB db = new ConnectDB();
        Boolean bResult = db.deleteDept(dpm);
        return bResult;
    }

    public Boolean UpdateDept(Department dpm)
    {
        ConnectDB db = new ConnectDB();
        Boolean bResult = db.editDept(dpm);
        return bResult;
    }
}
